/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 jfinal app. jfapp Group.
 */

define(['adminapp', 'spinner'], function ($app) {
    $app.navactive('booking_rule');

   $(".spinner_el").spinner({value:0, min: 0});

    $(".form_datetime1").datetimepicker({
        language      : 'zh-CN',
        autoclose     : true,
        isRTL         : App.isRTL(),
        format        : "yyyy-mm-dd hh:ii:ss",
        pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left")
    });

    $app.formvalidator({
    }, 'dataForm');

    var option_tpl = Handlebars.compile($("#option-template").html());

    $("#rule_brand").change(function(){
        var _this = this;
        var brandId = $(_this).val();
        $.post(g.ctx + "admin/booking/tableCategory/listByBrand", {brand: brandId}, function(data) {
            if (data.status == 'OK') {
                var html = option_tpl(data);
                $('#table_category_field').html(html);
                $('#table_category_field').select2({
                    placeholder: "餐桌类型"
                });
                /*var d = data.data;
                if (d.length > 0) {
                    $("#spinner_num").spinner({value:d[0].num, min: 0, max: d[0].num});
                    $("#spinner_dialy_degree").spinner({value:d[0].num, min: 0, max: d[0].num});
                }*/
            } else {
                $('#table_category_field').html("");
                $('#table_category_field').select2({
                    placeholder: "餐桌类型"
                });
            }
        });
    });

    /*$("#table_category_field").change(function() {
        *//*var $this = $(this);
        var num = $this.find('option[value="'+ $this.val() +'"]').attr("num");*//*
        //$("#spinner_num").spinner( "destroy" );;
        *//*$("#spinner_num").spinner({value:num, min: 0, max: num});
        $("#spinner_dialy_degree").spinner( "destroy" );
        $("#spinner_dialy_degree").spinner({value:num, min: 0, max: num});*//*
    });*/
});

